====== Core Overview ====== This is a walk through the source code during a request for ''/doku.php?id=start&do=show'' to explain the basics of DokuWiki. You should have the full source available when reading this to fully enjoy this journey. Use the [[https://codesearch.dokuwiki.org/xref/dokuwiki/|XRef]] links to obtain a browsable version of the source. There is also a more detailed [[callgraph]] page available including the rendering process. A lot of detail is left out of this description to make it simpler. ^ Filename ^ Code snippet ^ Description ^ | [[xref>doku.php]] | '' if(!defined('DOKU_INC')) '' | Everything starts here by defining the base code directory | | ::: | '' $ACT = $_REQUEST['do'] '' | next we determine which action is requested a.k.a. [[devel:action_modes|do modes]] | | ::: | '' require_once('init.php') '' | over to init.php, initialize core | | [[xref>inc/init.php]] | '' include('preload.php') '' | [[preload]] make it possible to override directories and configuration cascade | | ::: | '' if(!defined('DOKU_CONF') '' | create [[devel:environment]] defines for code location | | ::: | '' include(DOKU_INC. 'inc/config_cascade.php') '' | prepare and load the global [[configuration]] file(s) | | ::: | '' global $lang; '' | load and prepare the [[devel:localization|language]] files using English for all missing entries | | ::: | '' if(!defined('DOKU_REL') '' | create all [[devel:environment]] defines not already defined, which might be dependent of the [[:config]] settings | | ::: | '' if(!headers_sent() && .. '' | init session and set cookie | | ::: | '' require_once (DOKU_INC.'inc/load.php') '' | [[autoloader|autoload]] all libraries | | ::: | '' ... \\ auth_setup() \\ ... '' | initialize plugin controller, [[events|event handling]] system, authentication and exit after setting up mail | | [[xref>doku.php]] | '' $ID = getID() '' | back from init.php, sanitize and turn request into [[devel:environment|global variables]] | | ::: | '' $INFO = pageinfo() '' | add page [[devel:metadata]] into a [[devel:environment|global variable]], this includes calling [[xref>auth_quickaclcheck()]] and [[xref>p_get_metadata()]]. The later causing a rendering of page metadata if it isn't cached. | | ::: | '' if(!$INFO['exists'] ... '' | send 404 for missing pages | | ::: | '' trigger_event(DOKUWIKI_STARTED)'' | call [[action plugins]] subscribing the [[devel:event:dokuwiki_started|DOKUWIKI_STARTED]] event | | [[xref>inc/actions.php]] | '' act_dispatch($ACT) '' | do the work depending on [[devel:action_modes|action]] | | ::: | ''%%if ($evt->advise_before()) ...%%'' | allow plugins to override default behavior using [[devel:event:action_act_preprocess|ACTION_ACT_PREPROCESS]] event | | ::: | '' $ACT = act_clean($ACT) '' | sanitize and redirect [[config:disableactions|disabled actions]] into ''do=show'' | | ::: | '' ... \\ $ACT = act_permcheck($ACT) \\ ... '' | call processing code for requested action(s) while checking needed ACL permissions. The $ACT might change during [[xref>act_dispatch()]]. | | ::: | '' global $INFO \\ global $conf '' | make global variables accessible to template code | | ::: | '' trigger_event(ACTION_HEADERS_SEND) '' | call [[action plugins]] subscribing the [[devel:event:action_headers_send|ACTION_HEADERS_SEND]] event | | ::: | '' include(template('main.php')) '' | over to the selected template main script | | [[xref>lib/tpl/dokuwiki/main.php]] | '' ... \\ tpl_metaheaders() \\ ... '' | the [[template]] main script consist of HTML design elements calling on php methods for content like metaheaders, buttons, breadcrumb navigation elements etc. all available in the [[xref>inc/template.php]] file | | ::: | '' tpl_content() '' | here the actual wiki page is created | | [[xref>inc/template.php]] | ::: | ::: | | ::: | '' trigger_event(TPL_ACT_RENDER) '' | call to [[xref>tpl_content_core()]] using [[devel:event:tpl_act_render|TPL_ACT_RENDER]] event | | ::: | '' switch($ACT) '' | select content based on action, the basic ''do=show'' calls [[xref>html_show()]] | | [[xref>inc/html.php]] | '' $html = p_wiki_xhtml(...) '' | which uses a [[devel:caching#two-stage-caching|cached XHTML]] version of the page __OR__ triggers the [[parser|renderer]] to render cached instructions as XHTML __OR__ use the [[parser]] to turn wiki text into instructions first. | | [[xref>inc/template.php]] | '' trigger_event(TPL_CONTENT_DISPLAY) '' | back in [[xref>tpl_content()]] [[action plugins|action plugin's]] have a last chance to edit raw HTML before output by using [[devel:event:tpl_content_display|TPL_CONTENT_DISPLAY]] event | | [[xref>doku.php]] | '' trigger_event(DOKUWIKI_DONE) '' | finish by calling [[action plugins]] subscribing the [[devel:event:dokuwiki_done|DOKUWIKI_DONE]] event when the template main script has ended |